home *** CD-ROM | disk | FTP | other *** search
/ New Masters of Flash / New Masters of Flash.iso / pc / MOVIES / 14.dir / 00063_Text_text07.txt < prev    next >
Text File  |  2000-10-01  |  4KB  |  106 lines

  1. You can adapt this to create other effects. For example, you could create behaviors that make things appear/disappear, follow another clip, incorporate a transparency effect, resize things, and a lot more.
  2.  
  3. Putting the behavior clip inside another one allows you to change and update symbols quickly, which will be useful when youΓÇÖre working on big projects. Rather than changing each instance separately, you only need to change the clip inside the movie clip symbol.
  4. Now letΓÇÖs look at how we can modify the Shaking Behavior clip to change the _y, _rotation, _xscale, and _yscale properties. This time, weΓÇÖll put these actions in keyframe 1.
  5.  
  6. setProperty ("", _visible, 0);
  7. vTarget = "..";
  8. vDamp = 0.05;
  9. vGlobal_Strength = 3;
  10. vGlobal_attract = 0.2;
  11. // 
  12. vX_def = getProperty(vTarget, _x);
  13. vX_strength = 1;
  14. vX_attract = 1;
  15. vX = vX_def;
  16. // 
  17. vY_def = getProperty(vTarget, _y);
  18. vY_strength = 1;
  19. vY_attract = 1;
  20. vY = vY_def;
  21. // 
  22. vXscale_def = getProperty(vTarget, _xscale);
  23. vXscale_strength = 5;
  24. vXscale_attract = 2;
  25. vXscale = vXscale_def;
  26. // 
  27. vYscale_def = getProperty(vTarget, _yscale);
  28. vYscale_strength = 5;
  29. vYscale_attract = 2;
  30. vYscale = vYscale_def;
  31. // 
  32. vRot_def = 0;
  33. vRot_strength = 2;
  34. vRot_attract = 1;
  35. vRot = vRot_def;
  36. // 
  37. gotoAndStop ("Move_all");
  38. Comment: the viscosity parameter (formerly ΓÇÿdΓÇÖ)
  39.  
  40. damp = 0.05;
  41. Comment: the global brownian parameter (formerly ΓÇÿbΓÇÖ)
  42.  
  43. brown = 3;
  44.  
  45. Comment: the stiffness parameter (formerly ΓÇÿkΓÇÖ)
  46. stiff = 0.2;
  47.  
  48. gotoandStop (ΓÇ£Move_allΓÇ¥);
  49.  
  50. Note: We have particularized the parameters brown and stiff for each property (naming them x_brown, y_brown, xscale_brown, etcΓǪ). By doing this, we can apply a strong Brownian motion effect on the _x and _y properties and a weak effect on the _rotation property.
  51.  
  52. We have kept global parameters (still named damp, brown, stiff) that will be used as multipliers for all the properties (_x _y, _xscale, _yscale, _rotation).
  53. You will also see that Move_x keyframe has been relabelled to Move_all with the following code in that keyframe:
  54.  
  55. // vX
  56. vX_speed = Number(Number((1-vDamp)*vX_speed)+Number(vX_strength*((random(200)-100)/100)*vGlobal_Strength))+Number((vX_def-vX)*vX_attract*vGlobal_Attract);
  57. vX = Number(vX)+Number(vX_speed);
  58. // vY
  59. vY_speed = Number(Number((1-vDamp)*vY_speed)+Number(vY_strength*((random(200)-100)/100)*vGlobal_Strength))+Number((vY_def-vY)*vY_attract*vGlobal_Attract);
  60. vY = Number(vY)+Number(vY_speed);
  61. // vXScale
  62. vXScale_speed = Number(Number((1-vDamp)*vXScale_speed)+Number(vXScale_strength*((random(200)-100)/100)*vGlobal_Strength))+Number((vXScale_def-vXScale)*vXScale_attract*vGlobal_Attract);
  63. vXScale = Number(vXScale)+Number(vXScale_speed);
  64. // vYScale
  65. vYScale_speed = Number(Number((1-vDamp)*vYScale_speed)+Number(vYScale_strength*((random(200)-100)/100)*vGlobal_Strength))+Number((vYScale_def-vYScale)*vYScale_attract*vGlobal_Attract);
  66. vYScale = Number(vYScale)+Number(vYScale_speed);
  67. if (Number(vXscale)<0) {
  68.     vXscale = -vXscale;
  69. }
  70. if (Number(vYscale)<0) {
  71.     vYscale = -vYscale;
  72. }
  73. if (Number(vXscale)>500) {
  74.     vXscale = 500;
  75. }
  76. if (Number(vYscale)>500) {
  77.     vYscale = 500;
  78. }
  79. // vRot
  80. vRot_speed = Number(Number((1-vDamp)*vRot_speed)+Number(vRot_strength*((random(200)-100)/100)*vGlobal_Strength))+Number((vRot_def-vRot)*vRot_attract*vGlobal_Attract);
  81. vRot = Number(vRot)+Number(vRot_speed);
  82. // 
  83. setProperty (vTarget, _x, vX);
  84. setProperty (vTarget, _y, vY);
  85. setProperty (vTarget, _xscale, vXscale);
  86. setProperty (vTarget, _yscale, vYscale);
  87. setProperty (vTarget, _rotation, vRot);
  88. prevFrame ();
  89. Note that the formulae have been adapted to allow for global parameters. 
  90.  
  91. yscale_brown=10
  92. yscale_stiff=0
  93.  
  94. The other brownian and stiffness parameters  for all other properties (_x, _y, _xscale, _rotation) set to 0.
  95.  
  96. rot_brown=10
  97. rot_stiff=0
  98.  
  99. The other brownian and stiffness parameters  for all other properties (_x, _y, _xscale, _yscale) set to 0.
  100.  
  101. y_brown=10
  102. y_stiff=0
  103.  
  104. The other brownian and stiffness parameters  for all other properties (_x, _xscale, _yscale, _rotation) set to 0.
  105. Working out suitable parameters really is fun for behavioral animation programmers. I can spend hours playing around with the values of these parameters: you can discover all sorts of exciting and original effects while youΓÇÖre debugging the code.
  106.